
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sj" tagdir="/WEB-INF/tags/spring-jquery-tags"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<link rel="stylesheet" type="text/css" href="<c:url value='/css/jquery/flexigrid.pack.css' />" />
<script type="text/javascript" src="<c:url value='/js/jquery/flexigrid.pack.js' />"></script>
<script type="text/javascript" src="<c:url value='/js/util.js'/>"></script>
<script type="text/javascript" src="<c:url value='/js/payment-line-item.js'/>"></script>
<script type="text/javascript" src="<c:url value='/js/jquery/jquery.numeric.js'/>"></script>
<script type="text/javascript" src="<c:url value='/js/jquery/jquery.formatCurrency-1.4.0.pack.js'/>"></script>
<link href="<c:url value='/css/dhtmlxcombo_paylineitem.css' />"	rel="stylesheet" type="text/css" />
<script type="text/javascript">
	$(document).ready(function() {
		$('#pageTitle').text('<spring:message code="editPaymentrequest.heading.paymentReqView" />');
		
		var arr_projects = new Array();
		<c:forEach items="${cipeProjects}" var="project" varStatus="status">
    		var project${status.index} = new Object();
    		project${status.index}.id = '${project.id}';
    		project${status.index}.projectId = '${project.projectId}';
    		project${status.index}.projectType = '${project.projectTypeDesc}';
    		project${status.index}.title = '${project.escapedTitle}';
    		project${status.index}.status = '${project.status}';
    		project${status.index}.region = '${project.escapedRegion}';
    		project${status.index}.country = '${project.escapedCountry}';
    		project${status.index}.acronym = '${project.escapedAcronym}';
    		project${status.index}.formattedStartDate = '${project.formattedProjectStartDate}';
    		project${status.index}.formattedEndDate = '${project.formattedProjectEndDate}';
    		project${status.index}.partnerName = '${project.escapedPartnerName}';
    		project${status.index}.override = '${project.budgetOverride}';
    		project${status.index}.remainingFunds = ${project.remainingFundsPRExcluded};
    		project${status.index}.displayName = '${project.displayName}';
    		arr_projects[${status.index}] = project${status.index};
		</c:forEach>
		var arr_account_codes = new Array();
		<c:forEach items="${accountCodes}" var="accountCode" varStatus="status">
			var accountCode${status.index} = new Object();
			accountCode${status.index}.id = '${accountCode.id}';
			accountCode${status.index}.code = '${accountCode.code}';
			accountCode${status.index}.accountStatus = '${accountCode.accountStatus}';
			accountCode${status.index}.description = '<c:out value="${accountCode.escapedDescription}" />';
			accountCode${status.index}.displayName = '<c:out value="${accountCode.displayName}" />';
			arr_account_codes[${status.index}] = accountCode${status.index};
		</c:forEach>
		var arr_lineItems = new Array();
		<c:forEach items="${paymentrequest.lineItemBeans}" var="item" varStatus="status">
			var item${status.index} = new Object();
			item${status.index}.id = '${item.id}';
			item${status.index}.accountCodeId = '${item.accountCodeId}';
			item${status.index}.cipeProjectId = '${item.cipeProjectId}';
			item${status.index}.lineItemNumber = '${item.lineItemNumber}';
			item${status.index}.prevAmount = ${item.prevAmount};
			item${status.index}.amount = ${item.amount};
			arr_lineItems[${status.index}] = item${status.index};
		</c:forEach>
		
		var tabIndex = parseInt($('#comments').attr('tabindex'));
		var paymentLineItem = new com.cipe.cmrs.model.PaymentLineItem('paymentLineItems', arr_projects, arr_account_codes, arr_lineItems, tabIndex, function(totalAmount) {
			$('#amount').val(totalAmount);
			$('#amount').formatCurrency('#amountLabel',{colorize: true, negativeFormat: '(-%s%n)'});
		});
		$("#amount").val(${paymentrequest.amount});
		$('#amount').formatCurrency('#amountLabel',{colorize: true, negativeFormat: '(-%s%n)', roundToDecimalPlace: 2});
		
		$.validator.addMethod("drop_down_required", function(value, element) {
			return (value != "");
		}, "Please select an option.");
		
		$("#editPaymentrequestForm").validate({
			rules : {
				paymentTypeId : {
					drop_down_required : true
				},
				paymentMethod : {
					drop_down_required : true
				},
				payeeId : {
					drop_down_required : true
				},
				purposeOfExpenditure : {
					required : true
				}
			}
		});

// 		$('.pr-cancel-link').click(function() {
// 			$('<div>Request Cancellation of Payment Request?</div>').dialog({
// 				modal: true,
// 				height: 200,
// 				width: 300,
// 				dialogClass: 'confirmationDialog',
// 				buttons: 
// 			          {
// 						'Yes' : function() {
// 							$(this).dialog('close');
// 							$('#cancelPaymentRequest').click();
// 						},
// 						'No' : function() {
// 							$(this).dialog('close');
// 						}
// 			          },
// 			  	close: function(event, ui) {
// 			  		$(this).dialog('destroy');		  		
// 			  	}
// 			});
// 			return false;
// 		});
		 //prompt dialog box to allow user to enter cancellation request date   
        $('#setCancelStatus').click(function() {
        	$(this).bind("ajaxSend", function(){
                $('#loading').remove();
				$(this).after("<img  id='loading' src='<c:url value='/images/ajax-loader.gif'/>' alt='loading' />");
		
				 }).bind("ajaxComplete", function(){
		
					$('#loading').remove();
		
			 });
			$('<div>Request Cancellation of Payment Request?</div>').dialog({
				modal: true,
				height: 200,
				width: 300,
				dialogClass: 'confirmationDialog',
				buttons: 
			          {
						'Yes' : function() {
							$(this).dialog('close');
							dateCancellationRequest();
						},
						'No' : function() {
							$(this).dialog('close');
						}
			          },
			  	close: function(event, ui) {
			  		$(this).dialog('destroy');		  		
			  	}
			});
			return false;
		});
		 
        function dateCancellationRequest() {
      	var htmlString = '';
      	$('.form_cont').append('<div id="date-cancelRequest-container"></div>');        
          htmlString +='<br>'
          htmlString += '<label><spring:message code="editPaymentrequest.label.datecancelrequested"/>:&nbsp;</label><br/>';
          htmlString +='<input type="text" id="dateText" ></input>';           
          htmlString +='<div id="dateDiv"></div>';
          
   		var ui = $('#date-cancelRequest-container').append(htmlString);
    	  //bind the division with a datepicker
          $('#dateText').datepicker({
              changeMonth: true,
              changeYear: true,
              showButtonPanel: true,
              dateFormat: 'mm/dd/yy',
              onClose: function(dateText, inst) {              
                  $(this).datepicker('setDate', dateText);
              }
          });

          ui.dialog({
              title: 'Please Cancellation Request Date',
              autoOpen: false,
              width: 400,
              modal: true,
              resizable: false,
              close: function(event, ui) {
  				$(this).dialog('destroy');
  				 $('#date-cancelRequest-container').remove();
  			},
              buttons: {
                  "OK": function() {
                      var dateSelected = $('#dateText').val();
                      $(this).dialog("close");                          
                    
                    
                      if(dateSelected==null || dateSelected==""){
                          alert("Payment Request was not rejected. You must select the rejected date");                            	
                      }else {
                          $('#dateCancelRequested').val(dateSelected);	                          
                          $('#dateCancelRequested').removeAttr('disabled');
                        	$('#cancelPaymentRequest').click();
                      }
                      $('#date-cancelRequest-container').remove();
                  },
                  "Cancel": function() {
                      $(this).dialog("close");
                      $('#date-cancelRequest-container').remove();
                  }
              }
          });
          ui.dialog('open');
      }
      //prompt dialog box to allow user to enter resubmit date   
        $('#dummyReSubmitButton').click(function() {
        	$(this).bind("ajaxSend", function(){
                $('#loading').remove();
				$(this).after("<img  id='loading' src='<c:url value='/images/ajax-loader.gif'/>' alt='loading' />");
		
				 }).bind("ajaxComplete", function(){
		
					$('#loading').remove();
		
			 });
        	var htmlString = '';
        	$('.form_cont').append('<div id="date-reSubmit-container"></div>');        
            htmlString +='<br>'
            htmlString += '<label><spring:message code="editPaymentrequest.label.dateresubmitted"/>:&nbsp;</label><br/>';
            htmlString +='<input type="text" id="dateText" ></input>';           
            htmlString +='<div id="dateDiv"></div>';
            
     		var ui = $('#date-reSubmit-container').append(htmlString);
      	  //bind the division with a datepicker
            $('#dateText').datepicker({
                changeMonth: true,
                changeYear: true,
                showButtonPanel: true,
                dateFormat: 'mm/dd/yy',
                onClose: function(dateText, inst) {              
                    $(this).datepicker('setDate', dateText);
                }
            });

            ui.dialog({
                title: 'Enter reSubmission date',
                autoOpen: false,
                width: 400,
                modal: true,
                resizable: false,
                close: function(event, ui) {
    				$(this).dialog('destroy');
    				 $('#date-reSubmit-container').remove();
    			},
                buttons: {
                    "OK": function() {
                        var dateSelected = $('#dateText').val();
                        $(this).dialog("close");                          
                      
                      
                        if(dateSelected==null || dateSelected==""){
                            alert("Payment Request was not rejected. You must select the rejected date");                            	
                        }else {
                            $('#dateResubmitted').val(dateSelected);	                          
                            $('#dateResubmitted').removeAttr('disabled');
                          	$('#resubmit').click();
                        }
                        $('#date-reSubmit-container').remove();
                    },
                    "Cancel": function() {
                        $(this).dialog("close");
                        $('#date-reSubmit-container').remove();
                    }
                }
            });
            ui.dialog('open');
        });
		
		$("#creationDate").val($.format.date($("#creationDate").val(), "MM/dd/yyyy"));
		
		$("#updationDate").val($.format.date($("#updationDate").val(), "MM/dd/yyyy"));
		/*
			PRV5
			Print Payment Request' button - There should be a "dynamic button" which changes based on the 'Type' of payment request chosen.
			1) If the Payment Request Type = "Advance" or "Consultants/Contracts" or "Staff Reimbursements" or "Vendor Invoices" the button should read 'Print Payment Request Form', and should print the standard Payment Request form.
			2) If the Payment Request Type = "Partner Payment" the button should read 'Print Partner Payment Request Form', and should print the standard Partner Payment Request Form.
			3) If the Payment Request Type = "Reclass/Liquidation" the button should read 'Print Reclass Form', and should print the standard ReclassForm.		
		*/
		$("#paymentTypeId").change(function()
		{
			if(this.value==1 || this.value==2 || this.value==4 || this.value==6) {
				$('#printPaymentRequest').text('Print Payment Request Form');
				$('#printPaymentRequest').css('display','inline');
			}
			else if(this.value== 3) {
				$('#printPaymentRequest').text('Print Partner Payment Request Form');
				$('#printPaymentRequest').css('display','inline');
			} else if(this.value == 5){
				$('#printPaymentRequest').text('Print Reclass Form');
				$('#printPaymentRequest').css('display','inline');
			} else {
				$('#printPaymentRequest').css('display','none');
			}
		});
			
		$("#paymentTypeId").change();
		
		$('#printPaymentRequest').click(function() {
			$(this).bind("ajaxSend", function(){
                $('#loading').remove();
				$(this).after("<img  id='loading' src='<c:url value='/images/ajax-loader.gif'/>' alt='loading' />");
		
				 }).bind("ajaxComplete", function(){
		
					$('#loading').remove();
		
			 });
			var reportType = $('#printPaymentRequest').html();
			if($.trim(reportType) == 'Print Payment Request Form') {
				window.open("<c:url value='/secure/printPaymentRequestFormPdf.do' />?paymentRequestId=" + "${paymentrequest.id}", "_blank").focus();
			}
			if($.trim(reportType) == 'Print Partner Payment Request Form') {
				window.open("<c:url value='/secure/printPartnerPaymentRequestPdf.do' />?paymentRequestId=" + "${paymentrequest.id}", "_blank").focus();
			}
			if($.trim(reportType) == 'Print Reclass Form') {
				window.open("<c:url value='/secure/printReclassFormPdf.do' />?paymentRequestId=" + "${paymentrequest.id}", "_blank").focus();
			}
		});
		
		$('#printWireForm').click(function() {
			$(this).bind("ajaxSend", function(){
                $('#loading').remove();
				$(this).after("<img  id='loading' src='<c:url value='/images/ajax-loader.gif'/>' alt='loading' />");
		
				 }).bind("ajaxComplete", function(){
		
					$('#loading').remove();
		
			 });
			window.open("<c:url value='/secure/showBankWireTransferPdf.do' />?paymentRequestId=" + "${paymentrequest.id}", "_blank").focus();
		});
		
// 		$(function() {
// 			$("#receivedFromAccountingDate").datepicker("disable");
// 		});

// 		$(function() {
// 			$("#invoiceRequestDate").datepicker();
// 		});

// 		$(function() {
// 			$("#dateToFinanace").datepicker("disable");
// 		});

		$('.list-paymentrequest-link').click(function() {
			$(this).bind("ajaxSend", function(){
                $('#loading').remove();
				$(this).after("<img  id='loading' src='<c:url value='/images/ajax-loader.gif'/>' alt='loading' />");
		
				 }).bind("ajaxComplete", function(){
		
					$('#loading').remove();
		
			 });
			loadDiv('content', 'showPayeeList.do');
		});
		$('#instructions-link').click(function() {
			$(this).bind("ajaxSend", function(){
                $('#loading').remove();
				$(this).after("<img  id='loading' src='<c:url value='/images/ajax-loader.gif'/>' alt='loading' />");
		
				 }).bind("ajaxComplete", function(){
		
					$('#loading').remove();
		
			 });
			loadDiv('content', 'showInstructionsPaymentReq.do');
		});

		$('#b1').click(function() {
			loadDiv('content', $(this).attr('url'));
		});
		$('#b2').click(function() {
			loadDiv('content', $(this).attr('url'));
		});

		
		
		$('.close-button').click(function() {
			//loadDiv('content', 'refreshDashboard.do');
			window.location = '../secure/showDashboard.do';
	     });
		
		<c:choose>
			<c:when test="${empty canEdit || !canEdit}">
				var inputs = $('#editPaymentrequestForm input:not(.uneditable)');
				var selects = $('#editPaymentrequestForm select');
				var textareas = $('#editPaymentrequestForm textarea');
				for(var i = 0; i < inputs.length; i++) {
					inputs[i].readonly = true;
					if(inputs[i].type == 'text' || inputs[i].type == 'checkbox') {
						inputs[i].className = 'text_grey';	
					} else if(inputs[i].type == 'submit' || inputs[i].type == 'button') {
						inputs[i].className = 'gray_btn';
					}
				}
				for(var i = 0; i < selects.length; i++) {
					selects[i].disabled = true;
					selects[i].className = 'text_grey';
				}
				for(var i = 0; i < textareas.length; i++) {
					textareas[i].readonly = true;
					textareas[i].className = 'text_grey';
				}
			</c:when>
			<c:otherwise>
			
				toggleViewEditMode(true);
				
				$('#editButton').click(function() {
// 					$(this).bind("ajaxSend", function(){
// 	                       $('#loading').remove();
// 				$(this).after("<img  id='loading' src='<c:url value='/images/ajax-loader.gif'/>' alt='loading' />");

// 				 }).bind("ajaxComplete", function(){

// 					$('#loading').remove();

// 				 });
					toggleViewEditMode(false);
				});
				
				$('#cancelEditButton').click(function() {
					
					var ans = confirm('Are you sure you want to cancel editing this record without saving it?');
					if (ans) {
						$(this).bind("ajaxSend", function(){
			                $('#loading').remove();
							$(this).after("<img  id='loading' src='<c:url value='/images/ajax-loader.gif'/>' alt='loading' />");
					
							 }).bind("ajaxComplete", function(){
					
								$('#loading').remove();
					
						 });
						loadDiv('content', 'showEditPaymentrequest.do?id=${paymentrequest.id}');
					}
				});
				
			</c:otherwise>
		</c:choose>
		
		$('#payeeId').change(function() {
			if (this.value != '') {
				$('#add-paymentrequest-link').val('Edit');
				$('#payeeDesc').val($(':selected', this).text());
				loadDataViaAjax("getPayee.do", {
					"payeeId" : this.value
				}, function(bean) {
					$('#payeeAddress').val(bean.completeAddress);
				});
			} else {
				$('#add-paymentrequest-link').val('Add');
				$('#payeeDesc').val('');
				$('#payeeAddress').val('');
			}
		});
		
		$('#payeeId').change();		
		$('#save').click(function() {
			$(this).bind("ajaxSend", function(){
                $('#loading').remove();
				$(this).after("<img  id='loading' src='<c:url value='/images/ajax-loader.gif'/>' alt='loading' />");
		
				 }).bind("ajaxComplete", function(){
		
					$('#loading').remove();
		
			 });
			if(paymentLineItem.has6570or6571AccountCode()) {
    			open6570VerifyDialog(function(verified) {
    				$('#sixFiveSeventyVerify').prop('checked', verified);
    				$('#doSave').click();
    			});
			} else {
				$('#sixFiveSeventyVerify').prop('checked', false);
				$('#doSave').click();
			}
		});
	});
	
	function open6570VerifyDialog(okListener) {
		var ID_DIALOG_CONTAINER = 'test_ID_DIALOG_CONTAINER';

		var htmlString = '<div><input id="chk6570Verify" type="checkbox" />I verify that the deliverables have been received and accepted in accordance with the terms of the contract for this payment.</div>';
		var ui = $('<div id="' + ID_DIALOG_CONTAINER + '"></div>').append(htmlString);
		ui.dialog({
			modal: true,
			autoOpen : false,
			height: 250,
			width: 300,
			close: function(event, ui) {
				$(this).dialog('destroy');
			}
		});
		ui.dialog('option', 'buttons', {
			'OK' : function() {
				var verified = $('#chk6570Verify').prop('checked');
				$(this).dialog('close');
				$('#' + ID_DIALOG_CONTAINER).remove();
				if(okListener) {
					okListener(verified);
				}
			},
			'Cancel' : function() {
				$(this).dialog('close');
				$('#' + ID_DIALOG_CONTAINER).remove();
			}
		});
		ui.dialog('open');
	}
    $('#add-paymentrequest-link').click(function(){
    	$(this).bind("ajaxSend", function(){
			
			$('#loading').remove();
			$(this).after("<img  id='loading' src='<c:url value='/images/ajax-loader.gif'/>' alt='loading' />");

			 }).bind("ajaxComplete", function(){

				$('#loading').remove();

			 });

    });
	function toggleViewEditMode(viewMode) {
		var inputs = $('#paymentInfo input[type="text"]:not(.uneditable)');
		var selects = $('#paymentInfo select:not(.uneditable)');
		var textareas = $('#paymentInfo textarea:not(.uneditable)');
		if(viewMode)
			$("#invoiceRequestDate").datepicker("disable");
		else
			$("#invoiceRequestDate").datepicker();

		for(var i = 0; i < inputs.length; i++) {
// 			inputs[i].disabled = viewMode;
           if(viewMode)
			inputs[i].readonly = viewMode;
           else
           		$(inputs[i]).removeAttr("readonly");

			var className = '';
			if(viewMode) {
				className = 'text_grey';
				if(inputs[i].className.indexOf("input-full-width-req") != -1) {
					className = 'input-full-width-req ' + className;	
				}

				
			} else {
				if(inputs[i].className.indexOf("input-full-width-req") != -1) {
					className += 'input-full-width-req text_blue';	
				} else {
					className += 'text_white';
				}
			}
			inputs[i].className = className;
		}
		for(var i = 0; i < selects.length; i++) {
			selects[i].disabled = viewMode;
			var className = '';
			if(viewMode) {
				className = 'text_grey';
				if(selects[i].className.indexOf("input-full-width-req") != -1) {
					className = 'input-full-width-req ' + className;	
				}
			} else {
				if(selects[i].className.indexOf("input-full-width-req") != -1) {
					className += 'input-full-width-req text_blue';	
				} else {
					className += 'text_white';
				}
			}
			selects[i].className = className;
		}
		for(var i = 0; i < textareas.length; i++) {
			textareas[i].readonly = viewMode;
// 			textareas[i].disabled = viewMode;
			textareas[i].className = viewMode ? 'text_grey' : 'text_white';
		}

		var editPaymentBtn = $('#add-paymentrequest-link');
		if(viewMode) {
			editPaymentBtn.attr('disabled','disabled');
			editPaymentBtn.removeClass('blue_btn');
			editPaymentBtn.addClass('gray_btn');
		} else {
			editPaymentBtn.removeAttr('disabled');
			editPaymentBtn.removeClass('gray_btn');
			editPaymentBtn.addClass('blue_btn');
		}
		
		var lineItemInputs = $('#paymentLineItems input[type="text"]:not(.uneditable)');
		var lineItemSelects = $('#paymentLineItems select');
		for(var i = 0; i < lineItemInputs.length; i++) {
			lineItemInputs[i].readonly = viewMode;
			lineItemInputs[i].disabled = viewMode;
		}
		for(var i = 0; i < lineItemSelects.length; i++) {
			lineItemSelects[i].readonly = viewMode;
			lineItemSelects[i].disabled = viewMode;
		}
		
		if(viewMode) {
			$('#cancelEditButton').attr('disabled','disabled');
			$('#save').attr('disabled','disabled');
			
			$('#cancelEditButton').removeClass('blue_btn');
			$('#cancelEditButton').addClass('gray_btn');
			$('#save').removeClass('blue_btn');
			$('#save').addClass('gray_btn');
			
			$('#editButton').removeClass('gray_btn');
			$('#editButton').addClass('blue_btn');
		} else {
			$('#editButton').attr('disabled','disabled');
			$('#cancelEditButton').removeAttr('disabled');
			$('#save').removeAttr('disabled');
			
			$('#cancelEditButton').removeClass('gray_btn');
			$('#cancelEditButton').addClass('blue_btn');
			$('#save').removeClass('gray_btn');
			$('#save').addClass('blue_btn');
			
			$('#editButton').removeClass('blue_btn');
			$('#editButton').addClass('gray_btn');
		}
	}

</script>
<div id="editPaymentrequestDiv" >
	<form:form name="editPaymentrequestForm" id="editPaymentrequestForm" cssClass="main_form" action="showEditPaymentrequest.do" method="post" modelAttribute="paymentrequest">
		<c:set var="createdByCurrentUser">
			<c:choose>
				<c:when test="${currentUserId == paymentrequest.createdById }">
					true
				</c:when>
				<c:otherwise>
					false
				</c:otherwise>
			</c:choose>
		</c:set>
		<form:hidden path="id" />
        <form:checkbox id="sixFiveSeventyVerify" path="sixFiveSeventyVerify" cssClass="hiddenElement uneditable"/>
		<div class="form_head">
			<div class="floatL" style="padding-top:5px; width: 800px;">
			    <%-- allan-0424-3
				<a class="blue_btn" href="javascript://" id="b1" url="findResultCipeprojectWithProcedure.do?id=<c:out value='${paymentrequest.id}'/>&prc=getProjectList"><spring:message code="editPaymentrequest.label.viewRelatedProjects" /></a>
				<a class="blue_btn" href="javascript://" id= "b2" url="findResultPartnergrantWithProcedure.do?id=<c:out value='${paymentrequest.id}'/>&prc=getProjectGrantList"><spring:message code="editPaymentrequest.label.viewRelatedGrants" /></a>
                  --%>
				<%-- <a class="blue_btn" href="#"><spring:message code="editPaymentrequest.label.viewStatusHistory" /></a> --%>
				<a id="instructions-link" class="blue_btn" href="#"><spring:message code="editPaymentrequest.label.instructions" /></a>
				<a href="#" id="printWireForm" class="uneditable blue_btn"><spring:message code="editPaymentrequest.label.printWireForm" /></a>
				<a class="blue_btn" id="printPaymentRequest" href="#" style="display: none;" onclick="return false;">&nbsp;</a>
			</div>			
    		<a href="#" class="close-button gray_btn floatR" tabindex="-1">Close Form</a><br class="clear" />
    	</div>
    	<div class="form_cont">
			<table id="paymentInfo" class="fiveColTable" width="100%" cellspacing="1" cellpadding="0">
				<tr>
					<td colspan="5" style="font-size: 16pt; text-align: center;">
						<spring:message code="editPaymentrequest.heading.availableAction" />
					</td>
				</tr>
				<tr>
					<td colspan="4" style="text-align: right; padding-right: 30px;">
						<c:if test="${paymentrequest.statusCode == 'New' || paymentrequest.statusCode == 'Rejected' || paymentrequest.statusCode == 'Resubmitted'}">
							<sj:submit cssStyle="visibility: hidden; margin: 0; padding: 0; border: 0; float: left; width: 1px;" id="cancelPaymentRequest" target="editPaymentrequestDiv" key="editPaymentrequest.label.prCancel" validate="true" tabindex="-1"/>
							<input id="setCancelStatus" type="button" class="pr-cancel-link" value="<spring:message code="editPaymentrequest.label.prCancel" />" tabindex="-1"/>
						</c:if>
						<c:choose>
							<c:when test="${paymentrequest.statusCode == 'Rejected'}">
<%-- 								<sj:submit id="resubmit" target="editPaymentrequestDiv" key="editPaymentrequest.label.prResubmit" validate="true" /> --%>
							     <sj:submit id="resubmit" target="editPaymentrequestDiv" cssClass="uneditable" key="editPaymentrequest.label.prResubmit" validate="true" tabindex="-1" cssStyle="visibility: hidden; margin: 0; padding: 0; border: 0; float: left; width: 1px;"/>							    
							     <input type="button" id="dummyReSubmitButton" class="uneditable" value='<spring:message code="editPaymentrequest.label.prResubmit" />' tabindex="-1"/>
							    
							</c:when>
							<c:otherwise>
<%-- 								<sj:submit id="resubmit" attr="disabled='disabled'" target="editPaymentrequestDiv" key="editPaymentrequest.label.prResubmit" validate="true" /> --%>
							    <input type="button" id="dummyReSubmitButton" class="uneditable"  disabled="disabled" value='<spring:message code="editPaymentrequest.label.prResubmit" />' tabindex="-1"/>
							    
							</c:otherwise>
						</c:choose>
					</td>
                    <td style="padding-right: 20px; text-align: right;">
                        <%-- Blog268 <c:if test="${createdByCurrentUser}"> --%>
                          <input id="editButton" type="button" class="blue_btn" value="Edit">
                          <input id="cancelEditButton" type="button" class="gray_btn" value="Cancel Edit">
                              <%-- <spring:message code="button.cancel" /> --%>
                          <input id="save" type="button" class="gray_btn" disabled="disabled" value='<spring:message code="editPaymentrequest.button.save" />' tabindex="-1"/>
                          <sj:submit id="doSave" cssStyle="visibility: hidden; margin-right: 20px;"  cssClass="hiddenSubmitButton" target="editPaymentrequestDiv" key="editPaymentrequest.button.save" validate="true" tabindex="-1"/>
                        <%-- Blog268 </c:if> --%>
                    </td>				
				</tr>
				<tr class="row">
					<td colspan="5" style="text-align: center">
						<%@ include file="/common/messages.jsp" %>
					</td>
				</tr>
                  <tr>
                    <td class="label"><spring:message code="editPaymentrequest.label.paymentIdentifiedInformation" /></td>
                    <td class="input-field">
                      <form:input path="id" cssClass="input-full-width text_grey uneditable" readonly="true" tabindex="-1" style="font-size:2em"/>
                      <form:errors path="id" cssClass="error" />
                    </td>
                    <td class="fiveColSpacer">&nbsp;</td>
                    <td class="label"><spring:message code="editPaymentrequest.label.dateToFinanace" /></td>
                    <td class="input-field">
                    <form:input path="dateToFinanace" cssClass="input-full-width text_grey uneditable"  readonly="true" tabindex="-1"/>
                    <form:errors path="dateToFinanace" cssClass="error" />
                    </td>
                  </tr>
                  <tr>
                    <td class="label"><spring:message code="label.originator" /></td>
                    <td class="input-field">
                    <input type="text" value="${paymentrequest.createdBy }" class="input-full-width text_grey uneditable" readonly="readonly" tabindex="-1" />
                    <form:errors path="createdBy" cssClass="error" />
                    </td>
                    <td class="fiveColSpacer">&nbsp;</td>
                    <td class="label"><spring:message code="editPaymentrequest.label.dateforwardedforsignature" /></td>
                    <td class="input-field">
                    <form:input path="dateforwardedforsignature" cssClass="input-full-width text_grey uneditable"  readonly="true" tabindex="-1"/>
                    <form:errors path="dateforwardedforsignature" cssClass="error" />
                    </td>
                  </tr>
                  <tr>
                    <td class="label"><spring:message code="editPaymentrequest.label.datecreated" /></td>
                    <td class="input-field">
                    <form:input readonly="true" path="creationDate" cssClass="input-full-width text_grey uneditable" tabindex="-1"/>
                    </td>
                    <td class="fiveColSpacer">&nbsp;</td>
                    <td class="label"><spring:message code="editPaymentrequest.label.datesubmittedforpayment" /></td>
                    <td class="input-field">
                    <form:input path="datesubmittedforpayment" cssClass="input-full-width text_grey uneditable"  readonly="true" tabindex="-1"/>
                    <form:errors path="datesubmittedforpayment" cssClass="error" />
                    </td>
                  </tr>
                  <tr>
                    <td class="label"><spring:message code="editPaymentrequest.label.responsibleNextAct" /></td>
                    <td class="input-field">
                    <form:input path="currentlyresponsible" cssClass="input-full-width text_grey uneditable" readonly="true" tabindex="-1"/>
                    <form:errors path="currentlyresponsible" cssClass="error" />
                    </td>
                    <td class="fiveColSpacer">&nbsp;</td>
                    <td class="label"><spring:message code="editPaymentrequest.label.datepaid" /></td>
                    <td class="input-field">
                    <form:input path="datePaid" cssClass="input-full-width text_grey uneditable"  readonly="true" tabindex="-1"/>
                    <form:errors path="datePaid" cssClass="error" />
                    </td>
                  </tr>
                  <tr>
                    <td class="label" style="color: red"><spring:message code="editPaymentrequest.label.currentStatus" /></td>
                    <td class="input-field">
                    <span style="color:red"><form:input path="statusCode" cssClass="input-full-width text_grey uneditable" readonly="true" tabindex="-1"/></span>
                    <form:errors path="statusCode" cssClass="error" />
                    </td>
                    <td class="fiveColSpacer">&nbsp;</td>
                    <td class="label"><spring:message code="editPaymentrequest.label.daterejected" /></td>
                    <td class="input-field">
                    <form:input path="dateRejected" cssClass="input-full-width text_grey uneditable"  readonly="true" tabindex="-1"/>
                    <form:errors path="dateRejected" cssClass="error" />
                    </td>
                  </tr>
                  <tr>
                    <td class="label" style="vertical-align: top;"><spring:message code="editPaymentrequest.label.payee" /></td>
                    <td class="input-field" style="vertical-align: top;">
                    <form:select path="payeeId" cssStyle="width: 74%;" cssClass="input-full-width-req text_grey" disabled="true" tabindex="1">
                      <form:option value="" label="Select" />
                      <form:options items="${payeeList}" itemValue="id" itemLabel="payeeName" />
                    </form:select>
                    <form:hidden path="payeeDesc"/>
                    <sj:submit id="add-paymentrequest-link" nameKey="editPaymentrequest.button.addEditPayee" cssClass="gray_btn cancel" target="editPaymentrequestDiv" key="label.edit" tabindex="-1"/>
                    </td>
                    <td class="fiveColSpacer">&nbsp;</td>
                    <td class="label" style="vertical-align: top;"><spring:message code="editPaymentrequest.label.rejectedreason" /></td>
                    <td class="input-field">
                    <form:textarea path="reasonrejected" cssClass="input-full-width text_grey uneditable"  readonly="true" tabindex="-1" cssStyle="height: 45px;"/>
                    </td>
                  </tr>
                  <tr>
                    <td class="label"><spring:message code="editPaymentrequest.label.payeeAddress" /></td>
                    <td class="input-field">
                    <input id="payeeAddress" type="text" class="text_grey uneditable" readonly="readonly" tabindex="-1" />
                    </td>
                    <td class="fiveColSpacer">&nbsp;</td>
                    <td class="label"><spring:message code="editPaymentrequest.label.dateresubmitted" /></td>
                    <td class="input-field">
                    <form:input path="dateResubmitted" cssClass="input-full-width text_grey uneditable"  readonly="true" tabindex="-1"/>
                    <form:errors path="dateResubmitted" cssClass="error" />
                    </td>
                  </tr>
                  <tr>
                    <td class="label">Source Document Type</td>
                    <td class="input-field">
                    <form:select path="sourceDocumentType" cssClass="input-full-width text_grey" disabled="true" tabindex="2">
                      <form:option value="Invoice" label="Invoice" />
                      <form:option value="Account" label="Account" />
                      <form:option value="Contract" label="Contract" />
                      <form:option value="Reference #" label="Reference #" />
                    </form:select>
                    </td>
                    <td class="fiveColSpacer">&nbsp;</td>
                    <td class="label"><spring:message code="editPaymentrequest.label.datecancelrequested"/></td>
                    <td class="input-field">
                    <form:input path="dateCancelRequested" cssClass="input-full-width text_grey uneditable"  readonly="true" tabindex="-1"/>
                    <form:errors path="dateCancelRequested" cssClass="error" />
                    </td>
                  </tr>
                  <tr>
                    <td class="label"><spring:message code="editPaymentrequest.label.invoiceno" /></td>
                    <td class="input-field">
                    <form:input path="invoicenumber" cssClass="input-full-width  text_grey" readonly="true" tabindex="3"/>
                    <form:errors path="invoicenumber" cssClass="error" />
                    </td>
                    <td class="fiveColSpacer">&nbsp;</td>
                    <td class="label"><spring:message code="editPaymentrequest.label.datecancelled" /></td>
                    <td class="input-field">
                    <form:input path="dateCancelled" cssClass="input-full-width text_grey uneditable"  readonly="true" tabindex="-1"/>
                    <form:errors path="dateCancelled" cssClass="error" />
                    </td>
                  </tr>
                  <tr>
                    <td class="label"><spring:message code="editPaymentrequest.label.invoiceRequestDate" /></td>
                    <td class="input-field">
                    <form:input path="invoiceRequestDate" cssClass="input-full-width text_grey" readonly="true" tabindex="4"/>
                    <form:errors path="invoiceRequestDate" cssClass="error" />
                    </td>
                    <td class="fiveColSpacer">&nbsp;</td>
                    <td class="label"><spring:message code="editPaymentrequest.label.checkConfirmNumber" /></td>
                    <td class="input-field">
                    <form:input path="paymentConfirmationNumber" cssClass="input-full-width text_grey" readonly="true" tabindex="9"/>
                    <form:errors path="paymentConfirmationNumber" cssClass="error" />
                    </td>
                  </tr>
                  <tr>
                    <td class="label"><spring:message code="editPaymentrequest.label.paymentrequesttype" /></td>
                    <td class="input-field">
                    <form:select path="paymentTypeId" cssClass="input-full-width-req text_grey" disabled="true" tabindex="5">
                      <form:option value="" label="Select" />
                      <form:options items="${paymenttypeList}" itemValue="id" itemLabel="paymenttypename" />
                    </form:select>
                    <form:errors path="paymentTypeId" cssClass="error" />
                    </td>
                    <td class="fiveColSpacer">&nbsp;</td>
                    <td class="label"><spring:message code="editPaymentrequest.label.comments" /></td>
                    <td class="input-field">
                    <form:input path="comments" cssClass="input-full-width text_grey" readonly="true" tabindex="10"/>
                    <form:errors path="comments" cssClass="error" />
                    </td>
                  </tr>
                  <tr>
                    <td class="label"><spring:message code="editPaymentrequest.label.paymentmethod" /></td>
                    <td class="input-field"><form:select path="paymentMethod" cssClass="input-full-width-req text_grey" disabled="true" tabindex="6">
                      <form:option value="" label="Select" />
                      <form:option value="Wire" label="Wire" />
                      <form:option value="Check" label="Check" />
                      <%-- Commented due to ERR-24 
                      <form:option value="Other" label="Other" />
                      --%>
                    </form:select>
                    <form:errors path="paymentMethod" cssClass="error" />
                    </td>
                    <td class="fiveColSpacer">&nbsp;</td>
                    <td class="label"><spring:message code="editPaymentrequest.label.specialInstructions" /></td>
                    <td class="input-field">
                    <form:input path="specialInstructions" cssClass="input-full-width text_grey" readonly="true" tabindex="8"/>
                    <form:errors path="specialInstructions" cssClass="error" />
                    </td>
                  </tr>
                  <tr>
                    <td class="label"><spring:message code="editPaymentrequest.label.purposeOfExpenditure" /></td>
                    <td class="input-field">
                    <form:input path="purposeOfExpenditure" cssClass="input-full-width-req text_grey" dir="true" tabindex="7" readonly="true" />
                    <form:errors path="purposeOfExpenditure" cssClass="error" />
                    </td>
                    <td class="fiveColSpacer">&nbsp;</td>
                    <td class="label"><spring:message code="label.updatedBy" /></td>
                    <td class="input-field">
                    <input type="text" value="${paymentrequest.updatedBy }" class="input-full-width text_grey uneditable" readonly="readonly" tabindex="-1"/>
                    <form:errors path="updatedBy" cssClass="error" />
                    </td>
                  </tr>
                  <tr>
                    <td class="label"><spring:message code="editPaymentrequest.label.amount" /></td>
                    <td class="input-field">
                    <form:hidden path="amount" cssClass="input-full-width text_grey uneditable" />
                    <input type="text" value="&nbsp;" readonly="readonly"  id="amountLabel" class="text_grey uneditable" tabindex="-1" style="font-size: 2em;"/>
                    <form:errors path="amount" cssClass="error" />
                    </td>
                    <td class="fiveColSpacer">&nbsp;</td>
                    <td class="label"><spring:message code="label.updationDate" /></td>
                    <td class="input-field">
                    <form:input readonly="true" path="updationDate" cssClass="input-full-width text_grey uneditable" tabindex="-1"/>
                    <form:errors path="updationDate" cssClass="error" />
                    </td>
                  </tr>
			</table>
			<div id="paymentLineItems">
			</div>

		</div>
	</form:form>
	<script type="text/javascript">
		$(document).ready(function() {
			$('table.tablesorter').tablesorter({
				widgets : [ 'zebra' ],
				sortList : [ [ 0, 0 ], [ 1, 0 ] ],
				headers : {
					10 : {
						sorter : false
					}
				}
			});

			$('.edit-paymentrequestaward-link').click(function() {
				loadDiv('content', 'showEditPaymentrequest.do?id=' + $(this).attr('paymentrequestawardId'));
			});
		});
	</script>
</div>
